<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<title>历史退货订单明细(生产企业端)</title>
<%@ include file="/WEB-INF/component/commonCSS.jsp"%>
<!--[if lt IE 9]>
        <script src="lib/js/html5shiv.min.js"></script>
        <script src="lib/js/respond.min.js"></script>
    <![endif]-->
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
	<input type="hidden" id="typeflag" value='null'>
	<section class="content-header">
	<h1>历史退货单明细</h1>
	<ol class="breadcrumb">
		<li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i>首页</a></li>
			<li class="active"><a href="#">采购管理</a></li>
		<li class="active"><a href="#">退货单查看</a></li>
		<li class="active"><a href="#">历史退货单</a></li>
		<li class="active"><a href="#">历史退货单明细</a></li>
	</ol>
	</section>

	<section class="content">
	<div class=" box box-success">
		<div class="box-body">
			<form class=" form-inline" id='form'>
				
				<div class="form-group form-group-xs">
                       <label for="txtDrugComp">退货单状态：</label>
                       <select class="form-control" name="status" id = "status"  style="width: 140px;">
                       <option value="">请选择</option>
                       <option value="2">确认退货</option>
                       <option value="3">拒绝退货</option>
                       </select>
                 </div>
				<div class="form-group form-group-xs">
					退货日期： <input class="form-control" type="text"  name="submitStartDatetime" id="submitStartDatetime"
						dateFmt="yyyy-MM-dd" onFocus="var endDate=$dp.$('submitEndDatetime');WdatePicker({maxDate:'#F{$dp.$D(\'submitEndDatetime\')}'})" />
				
					<label>-</label>&nbsp;&nbsp;<input class="form-control" type="text" name="submitEndDatetime" id ="submitEndDatetime"
						dateFmt="yyyy-MM-dd" onFocus="WdatePicker({minDate:'#F{$dp.$D(\'submitStartDatetime\')}'})" />
				</div>
				<div class="form-group form-group-xs">
				确认日期： <input class="form-control" type="text"  name="confirmStartDatetime" id="confirmStartDatetime"
						dateFmt="yyyy-MM-dd" onFocus="var endDate=$dp.$('confirmEndDatetime');WdatePicker({maxDate:'#F{$dp.$D(\'confirmEndDatetime\')}'})" />
				
					<label>-</label>&nbsp;&nbsp;<input class="form-control" type="text" name="confirmEndDatetime" id ="confirmEndDatetime"
						dateFmt="yyyy-MM-dd" onFocus="WdatePicker({minDate:'#F{$dp.$D(\'confirmStartDatetime\')}'})" />
				</div>
				<div class="form-group form-group-xs">
					药品编码： <input class="form-control" type="text" name="drugCode"
						placeholder="药品编码" />
				</div>
				<div class="form-group form-group-xs">
					通用名： <input class="form-control" type="text" name="drugName"
						placeholder="通用名" />
				</div>
				<input hidden="true" name="retCode" value="${retCode}"/>
				<button type="button" class="btn btn-success btn-sm" onclick="gridSerch();" >查 询</button>
			</form>
		</div>
	</div>
	<table class="jqgrid" id="gridlist"></table>
	<div id="gridpage"></div>
	<div class="box box-warning bottongroup">
             <a href="${ctx }/purReturnOldOrder/toProCompReturnOldOrder.html" class="btn btn-default btn-sm">返 回</a>
        </div>
	</section>
	<%@ include file="/WEB-INF/component/commonJS.jsp"%>
	<script type="text/javascript">
	Date.prototype.Format = function (fmt,mon) { //author: meizz 
	    var o = {
	        "M+": this.getMonth() + 1+mon, //月份 
	        "d+": this.getDate(), //日 
	        "h+": this.getHours(), //小时 
	        "m+": this.getMinutes(), //分 
	        "s+": this.getSeconds(), //秒 
	        "q+": Math.floor((this.getMonth() + 3) / 3), //季度 
	        "S": this.getMilliseconds() //毫秒 
	    };
	    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
	    for (var k in o)
	    if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
	    return fmt;
	}
	gridSerch();
		$(function() {
			var date =  new Date();
			var lastDate = date.Format("yyyy-MM-dd",-1);
			var nowDate = date.Format("yyyy-MM-dd",0);
			$('#submitStartDatetime').val(lastDate);
			$('#submitEndDatetime').val(nowDate);
			$('#confirmStartDatetime').val(lastDate);
			$('#confirmEndDatetime').val(nowDate);
			var postJson = formatForm("form");
			$("#gridlist").jqGrid(
					{   url : "getProCompReturnOldOrderList.html",
						mtype : "POST",
						datatype : "json",
						postData:{retCode:"${retCode}"},
						autowidth : true,
						shrinkToFit : false,
						height : 255,
						colNames : [ '退货明细编号','退货价格','退货数量','金额','退货原因',"医疗机构地区",'药品编码 ','通用名 ','剂型 ','规格 ','转换系数 ','单位 ','材质 ','商品编码 ','退货时间','确认时间','确认状态',],
						colModel : [{name : 'retDetailCode',index : 'sdate',width : 210, sortable: false, align : "center",	
									},
									{name : 'proPrice',index : 'sdate',width : 60, sortable: false, align : "right",
			                        	   formatter:function(cellvalue, options, row){
			                                   return formatAmount(cellvalue, options, row);
			                               }},
									{name : 'retCount',index : 'sdate',width : 60, sortable: false, align : "center"},
									{name : 'retTotlePrice',index : 'sdate',width : 80, sortable: false, align : "right"},
									{name : 'retReason',index : 'sdate',width : 100, sortable: false, align : "center"},
									{name : 'areaName',index : 'arFullname',width : 100, sortable: false, align : "center"},
									{name : 'drugCode',index : 'stock',width :120, sortable: false, align : "center",
										formatter:function(cellvalue, options, row) {
											   return "<a href=\"javascript:$.HN.dialog.opendialog('"+row.drugId+"','"+cellvalue+"','${ctx}/stdDrug/drugInfoDetail.html?drugId="+row.drugId+"','800px','400px',function operResult(val){return operResult;})\">"+cellvalue+"</a>";
									  	}
									}, 
									{name : 'drugName',index : 'drugName',width : 140, sortable: false, align : "left"},
									{name : 'formName',index : 'formName',width : 80, sortable: false, align : "center"},
									{name : 'specName',index : 'specName',width : 80, sortable: false, align : "left"},
									{name : 'factor',index : 'factor',width : 80, sortable: false, align : "center"},
									{name : 'unit',index : 'unit',width : 40, sortable: false, align : "center"}, 
									{name : 'materialName',index : 'materialName',width : 80, sortable: false, align : "left"}, 
									{name : 'goodsCode',index : 'ship',width : 100, sortable: false, align : "center"},
									{name : 'submitTime',index : 'ship',width : 140, sortable: false, align : "center"},
									{name : 'confirmTime',index : 'ship',width : 140, sortable: false, align : "center"},
									{name : 'status',index : 'ship',width : 80, sortable: false, align : "center",
										formatter:function(cellvalue,options,rowdata){
											if (cellvalue == 1) {
												return '已提交';
											}else if(cellvalue == 2){
												return '确认退货';
											}else if(cellvalue == 3){
												return '拒绝退货';
											}else{
												return '其他';
											}
				                        } 
									}
									
						],
						rowNum : 20,
						rowList : [ 10, 20, 50,100],
						rownumbers : true,
						pager : "#gridpage",
						//multiselect: true, 
						viewrecords : true,
						caption : "${retCode}/${hospName}/${compName}",
						jsonReader : {
							repeatitems : false,
							id : "ids"
						}
					});
			$("#area1").HNSelect({
                url: "${ctx}/selectController/getArea.html", 
                data: { ID: '${sysAreaId}' }, 
                defaultText: "<option value=''>请选择</option>",
                defaultselect: "",
                func: function () {
                    $("#area2").HNSelect({
                        parent_selector: "#area1", 
                        url: "${ctx}/selectController/getArea.html", 
                        dataid: "ID", 
                        defaultText: "<option value=''>请选择</option>",
                        defaultselect: ""
                    });
                }
            });
			$("#gridlist").jqGrid('navGrid', '#gridpage', {add : false,edit : false,del : false,search : false,refresh : false});
			$(window).trigger("resize");
			
			  
		});
		 /*按条件查询*/
			   function gridSerch(){
					   var postJson = formatForm("form");
					   var strat = new Date( postJson['submitStartDatetime'].replace(/-/g,"/") );
					   var End = new Date( postJson['submitEndDatetime'].replace(/-/g,"/") );
					  //起始日期大于截至日期的判断
					   if (strat > End) {
						 var temp =postJson['submitStartDatetime'];
						 postJson['submitStartDatetime'] = postJson['submitEndDatetime'];
						 postJson['submitEndDatetime']= temp;
						 $("[name='submitStartDatetime']").val($("[name='submitEndDatetime']").val());
						 $("[name='submitEndDatetime']").val(temp);
						 temp=null;
					   }
			                $("#gridlist").jqGrid("clearGridData");
			                $("#gridlist").jqGrid('setGridParam',{  
			                
			                mtype: "POST",
			                datatype:'json',
			                postData:postJson,
			                page : 1
			            }).trigger("reloadGrid"); 
			   }
	</script>
</body>
</html>